package main

import "fmt"

func main() {
	//slice创建,从数组创建
	//var array = [...]int{0, 1, 2, 3, 4, 5, 6}
	//s1 := array[0:4] //指定起止索引
	//s2 := array[:4]  //指定结束索引
	//s3 := array[2:]  //指定开始索引
	//fmt.Printf("%v\n", s1)
	//fmt.Printf("%v\n", s2)
	//fmt.Printf("%v\n", s3)

	//slice创建,通过内置make函数创建
	//a := make([]int, 10)
	//b := make([]int, 10, 15)
	//a[9] = 10
	//fmt.Printf("%v\n", a)
	//fmt.Printf("%v\n", b)

	a := [...]int{0, 1, 2, 3, 4, 5, 6}
	b := make([]int, 2, 4)
	c := a[0:3]

	//fmt.Println(c)
	//fmt.Println(len(b))
	//fmt.Println(cap(b))

	b = append(b, 1)
	//fmt.Println(len(b))
	//fmt.Println(cap(b))

	b = append(b, c...)
	fmt.Println(b)
	fmt.Println(len(b))
	fmt.Println(cap(b))
}
